<?php

/**
 * departement actions.
 *
 * @package    SdCommerce
 * @subpackage departement
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class departementActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this->forward('default', 'module');
  }
  
   public function executeGetAllDepartement() {
        $departements= DepartementTable::getInstance()->findAll();
        $response = array();
        if (count($departements) > 0) {
            foreach ($departements as $i => $pro) {
                $departement = array();
                $departement["id"] = $pro->getId();
                $departement["libelle"] = $pro->getLibelle();

                $response["departements"][$i] = $departement;
            }
            $response["success"] = 1;
        } else {
            $response["success"] = 0;
            $response["message"] = "No departements found";
        }

        return $this->renderText(json_encode($response));
    }
}
